package cn.golxen.blog.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    @Bean
    public DirectExchange BlogExchange(){
        return new DirectExchange("blogExchange",true,false);
    }


    @Bean
    public Queue EssayQueue(){
        return new Queue("EssayQue",true);
    }
    @Bean
    public Queue CategoryQueue(){ return new Queue("CategoryQue",true);}
    @Bean
    public Queue AdminQueue(){return new Queue("AdminQue",true);}



    @Bean
    public Binding EssayBinding(){
        return BindingBuilder.bind(EssayQueue()).to(BlogExchange()).with("EssayKey");
    }
    @Bean
    public Binding CategoryBinding(){
        return BindingBuilder.bind(CategoryQueue()).to(BlogExchange()).with("CategoryKey");
    }
    @Bean
    public Binding AdminBinding(){
        return BindingBuilder.bind(AdminQueue()).to(BlogExchange()).with("AdminKey");
    }
}
